#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

template <class type>
float equation1(type a ,type b)
{
	if (0 != a)
		return (-b/a);
	else
		{
			cout<<"Error,because denominator can't be 0 !!!"<<endl;
			return 0;
		}
}

void equation2(float &a,float &b ,float &c )
{
	if ( 0==a )
		return 0;
	else
		{
			float del =b*b-4*a*c;
			float delta = sqrt(abs(del));
			c = -equation(a,b)>>1;
			b = delta;
			if ( del < 0 )
				a = -1;
			else
				a = 1;
				
		}
}

int main()
{
	int choose(1);
	cout << "Now you can choose one class[1] or two class[2] equation"<<endl;
	cin>>choose;
	switch (choose)
	{
		case '1':
		cout<<"Now need two parameters for calculation"<<endl;
		float a,b;
		cout <<"the const item,b==="<<endl;
		cin>> b;
		cout << "x's coeffience,a==="<<endl;
		cin>>a;
		cout << "The result of one class is "<<equation1(a,b)<<endl;
		break;
		
		case '2':
		cout<< "Now need three parameters for calculation"<<endl;
		float a,b,c;
		cout <<"the const item,c==="<<endl;
		cin>> c;
		cout << "x's coeffience,b==="<<endl;
		cin>>b;
		cout <<"x*x's coeffience,a==="<<endl;
		equation2(a,b,c);
		if (0==b)
			cout<< "The equation has only one slove"<<c<<endl;
		else
			{
				if ( 0 > a)
					cout<<"The equation has two image root"<<c<<"+j*"<<b<<" and "<<c<<"-j*"<<b<<endl;
				else 
					cout<<"The equation has two image root"<<c+b<<" and "<<c-b<<end;
			}
	}

}
